﻿using System;
using System.Threading.Tasks;

namespace NFinal.Hangfire.LoggerTest
{
    class Program
    {
        static void Main(string[] args)
        {
            //TaskTest();
            CancelTaskTest();
            Console.ReadKey(); ;
        }
        /// <summary>
        /// 测试一般任务
        /// </summary>
        private static void TaskTest()
        {
            SimpleService simpleService = new SimpleService();
            simpleService.Run(null);//hangfire中也传null
            CancelTaskTest();
        }
        /// <summary>
        /// 测试取消任务
        /// </summary>
        private static void CancelTaskTest()
        {
            var logger = NFinal.Common.TaskLogger.TaskLoggerFactory.GetTaskLogger(null);
            SimpleService simpleService = new SimpleService();
            Task.Factory.StartNew(() => simpleService.Inner(logger));
            Console.ReadKey();
            logger.CancelCurrentTask();
            Console.WriteLine("发送任务取消命令");
        }
    }
}
